package internal_test

import (
	"fmt"
	"testing"

	"gitcode.com/lin-xii/algorithm-and-structure/internal"
)

func TestFact(t *testing.T) {
	n := 3
	result := internal.Fact(n)
	fmt.Println(result)
}

func TestSum(t *testing.T) {
	list := []int{2, 4, 6}
	result := internal.Sum(list)
	if result != 12 {
		t.Errorf("expect result 12, got %+v", result)
	}

	list = []int{}
	result = internal.Sum(list)
	if result != 0 {
		t.Errorf("expect result 0, got %+v", result)
	}

	list = []int{2233}
	result = internal.Sum(list)
	if result != 2233 {
		t.Errorf("expect result 2233, got %+v", result)
	}

}

func TestCustomLen(t *testing.T) {
	list := []int{1, 3, 5, 7, 9}
	l := internal.CustomLen(list)
	fmt.Println(l)
}

func TestMax(t *testing.T) {
	list := []int{1, 3, 5, 7, 10}
	result := internal.Max(list)
	if result != 10 {
		t.Errorf("expect result 10, got %+v", result)
	}

	list = []int{10, 1, 1}
	result = internal.Max(list)
	if result != 10 {
		t.Errorf("expect result 10, got %+v", result)
	}

	list = []int{1, 10, 1}
	result = internal.Max(list)
	if result != 10 {
		t.Errorf("expect result 10, got %+v", result)
	}

	list = []int{}
	result = internal.Max(list)
	if result != 0 {
		t.Errorf("expect result 0, got %+v", result)
	}
}
